Skip to content

fix(surveys): honor choice option shuffling - #772

Merged
lucasheriques merged 2 commits into
mainfrom
lucas/surveys-shuffle-options
Sep 15, 2026
Merged

lucasheriques merged 2 commits into
mainfrom
lucas/surveys-shuffle-options

Conversation

@lucasheriques

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

Honor the existing shuffleOptions flag in Android Compose surveys, moving toward survey feature parity across all PostHog SDKs. Matches web behavior for single- and multiple-choice questions:

  • Shuffle regular choices, keeping Other last. False or absent keeps the configured order.
  • Preserve the order while selecting, typing and restoring saved UI state.
  • Keep the configured choice list unchanged so answers and branching still refer to the selected value.

The change lives in the shared choice renderer. No public API changes. Separate from partial responses/resume (#768) and auto-submit (#769); iOS counterpart: PostHog/posthog-ios#811.

💚 How did you test it?

  • make testSurveyUI: 25 tests passed, including 8 parameterized order tests and 8 mounted interaction cases. Covers both choice types, enabled/disabled shuffle, Other text, saved-state restoration, exact responses and advancing to a question with fewer choices.
  • CI=true make compile, Compose debug/release build, make checkRelease, formatting and the CodeScene safeguard passed.
  • Ignoring the flag in the renderer made all four enabled-shuffle interaction cases fail; disabled cases still passed. The order tests also cover web's unchanged-order fallback, empty/short lists and duplicate labels.

The additional build configuration and lockfile entries enable the Compose interaction tests in CI; runtime dependencies are unchanged.

📝 Checklist

  • Reviewed the code and added regression tests.
  • Added a patch changeset with pnpm changeset.
  • Public API unchanged.

🤖 Agent context

Autonomy: Human-driven (agent-assisted). Codex implemented and tested this through CLI tools. Human review is required.

Apply the existing shuffleOptions flag in the shared Compose choice UI.
Shuffle original indices, keep Other last and preserve the display order
through selection, text edits and saved-state restoration. Preserve the
configured choice list and submit the selected label or open-choice text.

Add parameterized order tests and eight mounted interaction cases covering
single/multiple selection, open choice, disabled shuffling, restoration,
response values and advancing to a question with a different choice count.
Run the Compose debug suite in CI and record its test dependency locks.

Verification: make testSurveyUI (25 tests); Compose build and local publish;
formatting and CodeScene safeguard passed. Full build/release verification
is recorded in the PR description.
@greptile-apps

greptile-apps Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
### Issue 1
posthog-android-surveys-compose/src/testDebug/java/com/posthog/android/surveys/compose/internal/ui/SurveyShuffleInteractionTest.kt:27-29
**Unclear Boolean parameter names**

The parameters `multiple`, `open`, and `shuffle` do not clearly communicate that they control multiple-choice mode, open-choice support, and option shuffling. This violates the repository directive to use variable names that clearly indicate their purpose. Rename them to descriptive names such as `isMultipleChoice`, `hasOpenChoice`, and `shouldShuffleOptions`; this repository requirement must be satisfied before merging.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "fix(surveys): honor choice option shuffl..." | Re-trigger Greptile

Use descriptive names for multiple-choice, open-choice and shuffle flags
in the parameterized UI tests, addressing the review comment on #772.

Validation: make testSurveyUI passes all 25 tests; make format succeeds.
CodeScene pre-commit safeguard reports no issues.
@lucasheriques
lucasheriques merged commit b3b0d22 into main Sep 15, 2026
16 checks passed
@lucasheriques
lucasheriques deleted the lucas/surveys-shuffle-options branch September 15, 2026 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants